Skip to content

Clarify that Tree.create_item(), Tree.set_columns() & Tree.clear() can fail & when.#1207

Merged
Arctis-Fireblight merged 1 commit intoRedot-Engine:masterfrom
AR-DEV-1:tree-create-item-doc-fix
Mar 8, 2026
Merged

Clarify that Tree.create_item(), Tree.set_columns() & Tree.clear() can fail & when.#1207
Arctis-Fireblight merged 1 commit intoRedot-Engine:masterfrom
AR-DEV-1:tree-create-item-doc-fix

Conversation

@AR-DEV-1
Copy link
Contributor

@AR-DEV-1 AR-DEV-1 commented Mar 4, 2026

TL;DR

This PR updates the documentation for Tree.create_item(), Tree.set_columns() & Tree.clear() & tells the user that all 3 methods can fail during mouse selection events. It also adds error messages for Tree.create_item(), Tree.set_columns() & Tree.clear()

The user will get the following error message if attempting to use any of the 3 methods during mouse selection events (Following RedMser's comment in godotengine/godot#105969 (review)):

image

(This is a test using the script provided by @kleonc in godotengine/godot#103101 (comment))

Text version:

E 0:00:02:715   tree.gd:14 @ _on_item_selected(): The tree cannot create items during mouse selection events.
  <C++ Error>   Condition "blocked > 0" is true. Returning: nullptr
  <C++ Source>  scene\gui\tree.cpp:5188 @ Tree::create_item()
  <Stack Trace> tree.gd:14 @ _on_item_selected()

(We use ERR_FAIL_COND_V_MSG instead of ERR_FAIL_COND_MSG here because Godot expects us to return a value or else we get build errors. We just return nullptr in this case.)

Note

Contributed by 2LazyDevs.

Summary by CodeRabbit

  • Documentation

    • Updated Tree class documentation to reflect error conditions for item creation, clearing operations, and column modifications during mouse selection.
  • Bug Fixes

    • Enhanced error reporting with descriptive messages when Tree operations fail during mouse selection events.

@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 87a9fd74-b154-493f-81cc-2f2b00b0579e

📥 Commits

Reviewing files that changed from the base of the PR and between 3ef8058 and 470ccad.

📒 Files selected for processing (2)
  • doc/classes/Tree.xml
  • scene/gui/tree.cpp

Walkthrough

Documentation and error handling enhancements for the Tree GUI class. Error messages are now attached to three operations that are disallowed during mouse selection: clearing the tree, creating items, and modifying column counts.

Changes

Cohort / File(s) Summary
Tree Documentation
doc/classes/Tree.xml
Updated method and property descriptions for clear(), create_item(), and columns to document error-printing behavior when operations are invoked during mouse selection.
Tree Error Handling
scene/gui/tree.cpp
Added descriptive error messages to three error checks in Tree::clear(), Tree::create_item(), and Tree::set_columns() when invoked during mouse selection (blocked > 0 condition).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main changes: adding clarification that three Tree methods can fail during mouse selection events, with explicit error messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@JoltedJon JoltedJon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Merged in on Godot's side already

Copy link
Contributor

@Arctis-Fireblight Arctis-Fireblight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@Arctis-Fireblight Arctis-Fireblight merged commit 101a613 into Redot-Engine:master Mar 8, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants